import { Body, Controller, Get, Post, Query, UsePipes } from '@nestjs/common'
import { MeetingService } from './services/meeting.service'
import { AuthorizeDto, MeetingRoomListDto } from './dtos'
import { SnakeCasePipe } from '@/pipes'

@Controller()
export class MeetingController {
  constructor(private readonly appService: MeetingService) {}

  // 提交预约参数
  @Post('/meeting-room/due')
  async dueMeetingRoom() {
    return await this.appService.dueMeetingRoom()
  }

  // 获取城市和分公司列表
  @Get('/meeting-room/predetermine')
  async predetermine() {
    return await this.appService.predetermine()
  }

  // 根据分公司名称和日期查询会议室
  @Get('/meeting-room/list')
  @UsePipes(SnakeCasePipe)
  async getMeetingRoomList(@Query() query: MeetingRoomListDto) {
    return await this.appService.getMeetingRoomList(query)
  }

  // 保存一个人的授权信息（cookie）
  @Post('/meeting-room/authorize')
  async authorize(
    @Body()
    body: AuthorizeDto
  ) {
    return await this.appService.authorize(body)
  }
}
